class PeopleController < ApplicationController
    def index
        @people=Person.all
    end

    def show
       @person=Person.find(params[:id])
    end

    def new 
        @person= Person.new
        @person.build_address
        @person.phones.build
        
    end

    def create
        @person= Person.new(params[:person])
        @person.save
        redirect_to @person
    end

    def destroy 
        @person= Person.find(params[:id])
        @person.destroy
        redirect_to people_url
    end 

    def list_egypt
        @people = Person.where('address.country' => 'Egypt')
    end  
end